<?php
require_once APPLICATION_PATH.'/models/Webinfo.php';
require_once APPLICATION_PATH.'/models/Navbar.php';
require_once APPLICATION_PATH.'/models/Kefu.php';

class BaseController extends Zend_Controller_Action{
    protected $webinfo;

    public function init()
    {
        /* Initialize action controller here */
        $url = constant("APPLICATION_PATH").DIRECTORY_SEPARATOR.'configs'.DIRECTORY_SEPARATOR.'application.ini';
        $dbconfig = new Zend_Config_Ini($url, "mysql");
        $db = Zend_Db::factory($dbconfig->db);

        $db->query('SET NAMES UTF8');
        Zend_Db_Table::setDefaultAdapter($db);

        //加载网站配置信息
        $this->initWebInfo();
        //加载导航条
        $this->initNavbar();
        //加载在线客服系统
        $this->initKefu();
    }

    protected function initWebInfo(){
        $twi = new Webinfo();
        $this->view->webinfo = $twi->fetchRow("id=1")->toArray();
    }

    protected function initNavbar(){
        $tnv = new Navbar();
        $where = "navbar.order!=0";
        $order = "order";
        $this->view->navbar = $tnv->fetchAll($where,$order)->toArray();
    }
    protected function initKefu(){
        $tkf = new Kefu();
        $kefuconf = $tkf->fetchRow("id=1")->toArray();

        $kfcode= '<script type="text/javascript">
    					var urlroot = "/public/addones/OnlineContact/images/";
    					var tOut = -1;
    					lastScrollY = 0;
    					</script>
    					<link rel="stylesheet" type="text/css" href="/public/addones/OnlineContact/style/default_blue.css"/>
    					<script language="javascript" src="/public/addones/OnlineContact/js/jquery.Sonline.js"></script>
    					<script type="text/javascript">
    					$(function(){
    						$("body").Sonline({
    							Position:"'.$kefuconf['xf_position'].'",
    							Top:'.$kefuconf['xf_top'].',
    							Width:'.$kefuconf['xf_width'].',
    							Effect:'.$kefuconf['xf_effect'].',
    							DefaultsOpen:'.$kefuconf['xf_defaultopen'].',
    							Tel:"'.$kefuconf['xf_tel'].'",
    							Qqlist:"'.$kefuconf['xf_qqlist'].'"
    						});
    					});
    					</script>';
        $this->view->kefu = $kfcode;
    }
}
